<template>
  <div class="result-statistics">
    <div class="title-span">
      <div class="left-box">
        <span class="title-font">方案评定结果统计</span>
        <div class="select-box">
          预报降雨类型：
          <el-select
            v-model="rainType"
            placeholder="请选择"
            filterable
            @change="handleGetResultArrList"
          >
            <el-option
              :key="index + item"
              v-for="(item, index) in rainTypeArr"
              :value="item.id"
              :label="item.name"
            />
          </el-select>
        </div>
        <!-- <span class="title-font">方案推荐度：</span>
        <span class="title-font">80%</span>
        <span class="title-link">推荐度说明</span> -->
        <!-- <span class="title-link" @click="handleOpenDescribe">推荐度说明</span> -->
      </div>
      <el-button type="info" class="btn-plus" link @click="handleOpenDialog">
        <el-icon>
          <FullScreen />
        </el-icon>
      </el-button>
    </div>
    <el-table border :data="resultArr" class="table-box" :span-method="objectSpanMethod">
      <el-table-column
        prop="blknm"
        label="预报断面"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        prop="fcProj"
        label="预报项目"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column label="预报方案精度" align="center">
        <el-table-column prop="ccNum" label="总场次" align="center"></el-table-column>
        <el-table-column prop="qualNum" label="合格场次" align="center"></el-table-column>
        <el-table-column prop="rate" label="合格率(%)" align="center"></el-table-column>
        <el-table-column prop="grade" label="等级" align="center"></el-table-column>
      </el-table-column>
    </el-table>
    <statistics-dialog ref="statisticsDialogRef" />
    <!-- 推荐度说明-->
    <describe-dialog ref="describeDialogRef" />
  </div>
</template>

<script setup>
import { ref, watch } from 'vue'
import StatisticsDialog from './cpns/statistics-dialog/index.vue'
import DescribeDialog from './cpns/describe-dialog/index.vue'
import { getCalcSchemeQual } from '@/services/modules/model-exam'
const props = defineProps({
  calcScid: {
    type: Number,
    default: 0
  }
})
const rainType = ref(null)
const statisticsDialogRef = ref(null)
const describeDialogRef = ref(null)
const resultArr = ref([])
// 预报降雨类型列表
const rainTypeArr = ref([
  { name: '全部', id: null },
  { name: '落地雨', id: 0 },
  { name: '数值预报', id: 2 },
  { name: '短临预报', id: 3 },
  { name: '短临+数值', id: 4 }
])
// 获取列表数据
const handleGetResultArrList = () => {
  getCalcSchemeQual({
    calcScid: props.calcScid,
    rainType: rainType.value
  }).then((res) => {
    if (res.code === 200) {
      resultArr.value = res.data
    }
  })
}
const handleOpenDialog = () => {
  statisticsDialogRef.value.handleOpenDialog(resultArr.value)
}
const handleOpenDescribe = () => {
  describeDialogRef.value.handleOpenDialog()
}
const objectSpanMethod = ({ row, column, rowIndex, columnIndex }) => {
  if (columnIndex === 0) {
    if (rowIndex % 5 === 0) {
      return {
        rowspan: 5,
        colspan: 1
      }
    } else {
      return {
        rowspan: 0,
        colspan: 0
      }
    }
  }
}
watch(
  () => props.calcScid,
  () => {
    handleGetResultArrList()
  },
  {
    immediate: true
  }
)
</script>

<style lang="less" scoped>
.result-statistics {
  height: 100%;
  .table-box {
    height: calc(100% - 50px);
  }
  .title-span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 10px 0 20px;
    height: 50px;
    .left-box {
      display: flex;
      align-items: center;
      width: calc(100% - 100px);
    }
    .btn-plus {
      font-size: 25px;
      font-weight: bold;
    }
    .title-font {
      font-size: 16px;
      font-weight: 600;
    }
    .title-link {
      font-weight: 600;
      font-size: 14px;
      margin-left: 40px;
      color: #409eff;
      cursor: pointer;
    }
    .select-box {
      margin: 0 60px 0 60px;
    }
  }
  .el-table {
    height: calc(100% - 50px);
    border-radius: 0 0 5px 5px;
  }
}
</style>
